home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
PROGRAMM
/
PASCAL
/
0391B.ZIP
/
INLINE2.ARC
/
INLINE.DOC
next >
Wrap
Text File
|
1986-07-28
|
12KB
|
331 lines
July 28, 1986
INLINE ASSEMBLER
Version 2.02
OVERVIEW
INLINE.COM is an assembler designed to produce Inline 8086/8088
and 8087 code for Turbo Pascal (tm) version 3 programs. Like
other assemblers, INLINE accepts as input an assembly language
source file and produces an object file. However, in this case,
the 'object' file is an ASCII file consisting of Inline
statements which may be inserted into the Turbo Pascal program.
Figure 1 illustrates a Pascal function with Inline code generated
by INLINE using the source file of Figure 2.
LOADING AND RUNNING INLINE
First create a COM file, INLINE.COM, by compiling INLINE.PAS
using the Turbo Pascal compiler. The normal default memory
settings are suitable.
INLINE is called at the DOS prompt with two filename parameters
specifying the names of the source and object files. If no
extensions are given, .ASM and .OBJ are used by default. For
instance,
INLINE ABC DEF
will cause INLINE to look for a source file, ABC.ASM, and create
an object file, DEF.OBJ. Files with no extension may be input or
created by using a simple '.' for the extension.
If the object filename is missing from the command line, an OBJ
file will be created using the same name as the source file. If
neither filename is specified, then names will be requested once
execution starts.
Once execution begins, INLINE will run to completion with the
only console output being error messages.
SYNTAX
The appendix lists the mnemonics accepted by INLINE. Syntax and
mnemonics correspond to that used by most assemblers but note
should be made of the following:
1
1. Turbo Pascal symbols may be used within instruction entries
by preceding the symbol with a '>' (16 bit symbol) or a '<'
(8 bit symbol). The characters '+' and '-' are considered
part of the symbol. This allows computations using symbols
to be passed on to the compiler where the computation can be
made. For instance, in
MOV AX,[>SYMBOL+4] ;'>SYMBOL+4' is passed on
MOV AX,[BP+>SYMBOL+4] ;again '>SYMBOL+4' is passed on
MOV AX,>SYMBOL+4[BP] ;also acceptable
Note that
MOV AX,[>SYMBOL+4+BP]
is not correct since the wrong instruction will be generated
and '>SYMBOL+4+BP' will be passed on.
2. Labels (for use with jump instructions) may be defined
simply by appending a ':' to the first item on a line.
Avoid using CS:, DS:, ES:, and SS: as labels, as these
specify segment overrides.
3. Numerical entries are assumed to be decimal unless preceded
by a '$' indicating a hexadecimal entry. Characters within
single quotes may be used for numerical entries as:
CMP AL,'a'
4. Square brackets are used to indicate 'contents of'. If no
square brackets are used, an immediate operand is assumed.
MOV AX,[>DATA] ;Load AX with the contents of DATA.
MOV AX,>DATA ;Load AX with DATA.
5. Instruction prefixes and segment override prefixes may
precede the instruction on the same line or may be included
on a previous line. A colon is optional after the segment
prefix.
ES: MOV AX,[1234] ;ok
REPNE MOVSB ;ok
MOV AX,ES:[1234] ;incorrect syntax for INLINE
6. Comments may be included in the source. They are delimited
by a ';'.
7. Instructions which don't clearly specify the data size
require that BYTE PTR, WORD PTR, DWORD PTR, QWORD PTR, or
TBYTE PTR be used. These may be abbreviated by using the
first two letters.
2
INC BYTE PTR [>BDATA]
DEC WO >WARRAY[DI]
FLD QWORD [>DBL_REAL]
8. JMP instructions may use SHORT, NEAR, or FAR (they should
not be abbreviated). In the absence of one of these words, a
SHORT jump will be encoded if the label is already defined
and is within range. If the label is not defined, a NEAR
JMP will be encoded unless SHORT is used.
A FAR CALL or JMP may be made to a direct address by stating
both the segment and offset separated by a colon.
CALL FAR $1234:$5678
RESTRICTIONS
The object file is limited to 32k. This includes comments and
spaces.
Symbols (including any addons from + and -) are limited to 32
characters.
Labels may be used in jump statements only and not as data
references. While there is a DB pseudo-opcode, it is not very
useful with this restriction.
The number of statement labels that may be defined is limited
only by the heap space available.
VERSIONS
2.00 Added 8087 instructions.
2.01 Fixed bug which wiped out INT $A vector.
2.02 Fixed bug which prevented labels from starting with BY, WO,
DW, QW, and TB.
(C) Copyright 1985,86 by L. David Baldwin.
INLINE may be copied and distributed freely providing that no fee
is charged and it is not part of a package for which a charge is
made.
Please report all bugs, suggestions, and problems to Dave
Baldwin, CompuServe ID #76327,53.
22 Fox Den Rd., (Summer) 144 13th St. East, (Winter)
Hollis, NH 03049 Tierra Verde, FL 33715
(603) 465-7857 (813) 867-3030
Turbo Pascal is a trademark of Borland International Inc.
3
FUNCTION SCAN(LIMIT :INTEGER; CH :CHAR; VAR T ): INTEGER;
{SCAN LIMIT CHARACTERS FOR CH. RETURN THE NUMBER OF CHARACTERS
SKIPPED TO FIND A MATCH. IF NOT FOUND, RETURN RESULT=LIMIT.
LIMIT MAY BE NEGATIVE FOR A BACKWARDS SCAN.}
BEGIN {SCAN MUST BE FAST--USE ASSEMBLY LANGUAGE}
Inline(
$FC { CLD ;ASSUME FORWARD}
/$8A/$46/<CH { MOV AL,<CH[BP] ;CHAR TO SEARCH FOR}
/$8B/$4E/<LIMIT { MOV CX,<LIMIT[BP];BYTES TO SEARCH}
/$09/$C9 { OR CX,CX ;CHECK SIGN}
/$9C { PUSHF ;SAVE FLAGS}
/$79/$03 { JNS X1}
/$F7/$D9 { NEG CX ;MAKE POSITIVE}
/$FD { STD ;BUT SEARCH IN REVERSE}
/$89/$CA {X1: MOV DX,CX ;SAVE FULL COUNT}
/$C4/$7E/<T { LES DI,<T[BP] ;PTR TO START}
/$F2/$AE { REPNE: SCASB ;SEARCH}
/$75/$01 { JNE X2}
/$41 { INC CX ;FOUND A MATCH}
/$29/$CA {X2: SUB DX,CX ;FIND COUNT TO MATCH}
/$9D { POPF}
/$79/$02 { JNS X3}
/$F7/$DA { NEG DX ;MAKE NEGATIVE IF REVERSE}
/$89/$56/$0C {X3: MOV [BP+$C],DX ;PUT IN FUNCTION RESULT}
);
END;
Figure 1: Pascal Function using Inline Code
CLD ;ASSUME FORWARD
MOV AL,<CH[BP] ;CHAR TO SEARCH FOR
MOV CX,<LIMIT[BP];BYTES TO SEARCH
OR CX,CX ;CHECK SIGN
PUSHF ;SAVE FLAGS
JNS X1
NEG CX ;MAKE POSITIVE
STD ;BUT SEARCH IN REVERSE
X1: MOV DX,CX ;SAVE FULL COUNT
LES DI,<T[BP] ;PTR TO START
REPNE: SCASB ;SEARCH
JNE X2
INC CX ;FOUND A MATCH
X2: SUB DX,CX ;FIND COUNT TO MATCH
POPF
JNS X3
NEG DX ;MAKE NEGATIVE IF REVERSE
X3: MOV [BP+$C],DX ;PUT IN FUNCTION RESULT
Figure 2: INLINE Input File
4
APPENDIX
8086/8088 Opcode Mnemonics Recognized by INLINE
AAA HLT JNE LOOPNZ ROR
AAD IDIV JNG LOOPZ SAHF
AAM IMUL JNGE MOV SAL
AAS IN JNL MOVSB SAR
ADC INC JNLE MOVSW SBB
ADD INT JNO MUL SCASB
AND INTO JNP NEG SCASW
CALL IRET JNS NOP SHL
CBW JA JNZ NOT SHR
CLC JAE JO OR SS
CLD JB JP OUT STC
CLI JBE JPE POP STD
CMC JC JPO POPF STI
CMP JCXZ JS PUSH STOSB
CMPSB JE JZ PUSHF STOSW
CMPSW JG LAHF RCL SUB
CS JGE LDS RCR TEST
CWD JL LEA REP WAIT
DAA JLE LES REPE XCHG
DAS JMP LOCK REPNE XLAT
DB JNA LODSB REPNZ XOR
DEC JNAE LODSW REPZ
DIV JNB LOOP RET
DS JNBE LOOPE RETF
ES JNC LOOPNE ROL
8087 Opcode Mnemonics Recognized by INLINE
F2XM1 FDIVRP FLD FNOP FSTP
FABS FENI FLD1 FNSAVE FSTSW
FADD FFREE FLDCW FNSTCW FSUB
FADDP FIADD FLDENV FNSTENV FSUBP
FBLD FICOM FLDL2E FNSTSW FSUBR
FBSTP FICOMP FLDL2T FPATAN FSUBRP
FCHS FIDIV FLDLG2 FPREM FTST
FCLEX FIDIVR FLDLN2 FPTAN FXAM
FCOM FILD FLDPI FRNDINT FXCH
FCOMP FIMUL FLDZ FRSTOR FXTRACT
FCOMPP FINCSTP FMUL FSAVE FYL2X
FDECSTP FINIT FMULP FSCALE FYL2XP1
FDISI FIST FNCLEX FSQRT FWAIT
FDIV FISTP FNDISI FST
FDIVP FISUB FNENI FSTCW
FDIVR FISUBR FNINIT FSTENV
5